#ifndef __MALICE_TRACE_NODE_HPP__
#define __MALICE_TRACE_NODE_HPP__

#include <string>

#include <boost/config.hpp>
#include <boost/current_function.hpp>
#include <MAlice/Parser/location.hh>

using namespace yy;
using namespace std;
class Trace;
class TraceNode;

struct TraceHandler {
	TraceNode* node;
	TraceHandler(TraceNode* node);
	~TraceHandler();
};

class TraceNode {
private:
	string mFile;
	int    mLine;
	string mFunc;
	location mLocation;

public:
	TraceNode(const char* file, int lineNumber, const char* functionName, location location);
	~TraceNode();

	void print (std::ostream& os, int indent);
};


#define _MALICE_TRACE_UID 	BOOST_JOIN(BOOST_JOIN(BOOST_JOIN(malice_trace, __COUNTER__), _L_), __LINE__)
#define MALICE_TRACE 		::TraceHandler _MALICE_TRACE_UID (new TraceNode(BOOST_STRINGIZE(__FILE__), __LINE__, BOOST_CURRENT_FUNCTION, mLocation))

#endif /* __MALICE_TRACE_NODE_HPP__ */
